{% load i18n %}
{% load custom_translation %}
{% load humanize %}

{% with run_name=run.name %}

<h3 class="is-size-3 mt-3"> {% trans "Data Generation" %} </h3>

{% blocktrans with ncontrib=num_total_contributors_this_run ntrainrows=total_num_training_rows_this_run|intcomma ntraingames=total_num_training_games_this_run|intcomma nratgames=total_num_rating_games_this_run|intcomma %}
Across all time, {{ ncontrib }} distinct users have uploaded {{ ntrainrows }} rows of training data, {{ ntraingames }} training games, and {{ nratgames }} rating games.
{% endblocktrans %}

{% if num_recent_contributors_this_run > 0 %}
<p>
{% blocktrans with ncontrib=num_recent_contributors_this_run ntrainrows=num_recent_training_rows_this_run|intcomma ntraingames=num_recent_training_games_this_run|intcomma nratgames=num_recent_rating_games_this_run|intcomma %}
In the last week, {{ ncontrib }} distinct users have uploaded {{ ntrainrows }} rows of training data, {{ ntraingames }} new training games, and {{ nratgames }} new rating games.
{% endblocktrans %}
{% endif %}

{% if num_day_contributors_this_run > 0 %}
<p>
{% blocktrans with ncontrib=num_day_contributors_this_run ntrainrows=num_day_training_rows_this_run|intcomma ntraingames=num_day_training_games_this_run|intcomma nratgames=num_day_rating_games_this_run|intcomma %}
In the last 24h, {{ ncontrib }} distinct users have uploaded {{ ntrainrows }} rows of training data, {{ ntraingames }} new training games, and {{ nratgames }} new rating games.
{% endblocktrans %}
{% endif %}

<p>
{% url 'game_network_groups' run_name as games_url %}
{% blocktrans %}
Look up and view games for this run <a href="{{ games_url }}">here</a>.
{% endblocktrans %}


<h3 class="is-size-3 mt-3"> {% trans "Networks" %} </h3>

{% url 'networks' run_name as networks_url %}
{% blocktrans %}
A total of <a href="{{ networks_url }}">{{ num_networks_this_run_excluding_random }} networks</a> have been uploaded for {{ run_name }}.
{% endblocktrans %}

<p>
{% if latest_network and latest_network.model_file %}
<span class="has-text-weight-medium">{% trans "Latest network" %}:</span> <a href="{{ latest_network.model_download_url }}">{{ latest_network.name }}</a>
{% endif %}
<p>
{% if strongest_confident_network and strongest_confident_network.model_file %}
<span class="has-text-weight-medium">{% trans "Strongest confidently-rated network" %}:</span> <a href="{{ strongest_confident_network.model_download_url }}">{{ strongest_confident_network.name }}</a>
{% endif %}

<h5 class="is-size-5 mt-3"> {% trans "Approximate Elo Ratings Graph" %} </h3>

{% blocktrans with num_rating_games=total_num_rating_games_this_run|intcomma %}
Graph is based on about {{ num_rating_games }} rating games using mid to high hundreds of playouts. Ratings might still be mildly inflated due to only playing other KataGo nets, but otherwise are fresh and unbiased and involve a variety of nets to avoid rock-paper-scissors. Vertical bars indicate approximately a 95% confidence interval.
<p class="mt-2">
Click and drag to zoom. Double-click or click on a button to reset zoom.
{% endblocktrans %}

<div id="eloGraphButtons" class="mt-2">
{% blocktrans %}
<button id="eloGraphTimeButton" class="button eloGraphButton">By Upload Time</button>
<button id="eloGraphDataRowsButton" class="button eloGraphButton">By Data Rows (linear)</button>
<button id="eloGraphDataRowsLogButton" class="button eloGraphButton">By Data Rows (log)</button>
{% endblocktrans %}
{% blocktrans %}
<button id="eloGraphDataRowsLogRecentButton" class="button eloGraphButton">By Data Rows (log, recent)</button>
{% endblocktrans %}
</div>

<div id="eloGraph"></div>


<h3 class="is-size-3 mt-3"> {% blocktrans %} Top Contributors {% endblocktrans %} </h3>

{% url 'contributions' run_name as contributions_url %}
{% blocktrans %}
See <a href="{{ contributions_url }}">here</a> for a full list of contributors for {{ run_name }}.
{% endblocktrans %}

{% if num_day_contributors_this_run > 0 %}
<h4 class="is-size-4 mt-4"> {% blocktrans %} In the Last 24h {% endblocktrans %} </h4>

<table class="table">
  <tr>
    <th> {% trans "User" %} </th>
    <th class="has-text-right">
      {% trans "Training Rows" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Data rows that KataGo learns from, each is a position sampled from training games, weighted towards more interesting positions."></i>
    </th>
    <th class="has-text-right">
      {% trans "Training Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games that KataGo plays against itself to generate training rows."></i>
    </th>
    <th class="has-text-right">
      {% trans "Rating Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games between different networks to measure strength and compute Elo ratings."></i>
    </th>
  </tr>
  {% for user in top_day_user_list %}
  <tr>
    <td> {{ user.username }} </td>
    <td class="has-text-right"> {{ user.total_num_training_rows|as_n_training_rows_str }} </td>
    <td class="has-text-right"> {{ user.total_num_training_games|as_n_training_games_str }} </td>
    <td class="has-text-right"> {{ user.total_num_rating_games|as_n_rating_games_str }} </td>
  </tr>
  {% endfor %}
</table>

{% endif %}


{% if num_recent_contributors_this_run > 0 %}
<h4 class="is-size-4 mt-4"> {% blocktrans %} In the Last Week {% endblocktrans %} </h4>

<table class="table">
  <tr>
    <th> {% trans "User" %} </th>
    <th class="has-text-right">
      {% trans "Training Rows" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Data rows that KataGo learns from, each is a position sampled from training games, weighted towards more interesting positions."></i>
    </th>
    <th class="has-text-right">
      {% trans "Training Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games that KataGo plays against itself to generate training rows."></i>
    </th>
    <th class="has-text-right">
      {% trans "Rating Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games between different networks to measure strength and compute Elo ratings."></i>
    </th>
  </tr>
  {% for user in top_recent_user_list %}
  <tr>
    <td> {{ user.username }} </td>
    <td class="has-text-right"> {{ user.total_num_training_rows|as_n_training_rows_str }} </td>
    <td class="has-text-right"> {{ user.total_num_training_games|as_n_training_games_str }} </td>
    <td class="has-text-right"> {{ user.total_num_rating_games|as_n_rating_games_str }} </td>
  </tr>
  {% endfor %}
</table>

{% endif %}


<h4 class="is-size-4 mt-4"> {% blocktrans %} Overall {% endblocktrans %} </h4>

<table class="table">
  <tr>
    <th> {% trans "User" %} </th>
    <th class="has-text-right">
      {% trans "Training Rows" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Data rows that KataGo learns from, each is a position sampled from training games, weighted towards more interesting positions."></i>
    </th>
    <th class="has-text-right">
      {% trans "Training Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games that KataGo plays against itself to generate training rows."></i>
    </th>
    <th class="has-text-right">
      {% trans "Rating Games" %}
      <i class="fas fa-info-circle info-circle-light" tabindex="-1" title="Games between different networks to measure strength and compute Elo ratings."></i>
    </th>
  </tr>
  {% for user in top_total_user_list %}
  <tr>
    <td> {{ user.username }} </td>
    <td class="has-text-right"> {{ user.total_num_training_rows|as_n_training_rows_str }} </td>
    <td class="has-text-right"> {{ user.total_num_training_games|as_n_training_games_str }} </td>
    <td class="has-text-right"> {{ user.total_num_rating_games|as_n_rating_games_str }} </td>
  </tr>
  {% endfor %}
</table>



{% endwith %}
